import { successResp, ReportFile } from '../../core/common'
import MockStore from '../../ipc/mockstore'

const HOME_PATH = '/home/s5000/';
/**
 * mock文件有两个作用，一是作为和C++桥接的接口定义，二是为支持前后段分离的前端调试
 *
 * API reference
 * https://esti-bd.yuque.com/teid1h/project_doc/lkfu3bmd9gwheumr#ailwB
 */
class MyMockStore extends MockStore {
  constructor() {
    super('[report]');
  }

  initialize() {

    const DATA_REPORTS = [
      {
        "directory_id": 1,
        "id": 1,
        "report_name": "#1PCS运行日报表",
        "report_type": 1,
        "generate_time": "",
        "generate_node": "",
        "generate_path": "",
        "generate_subdirectory": false
      },
      {
        "directory_id": 1,
        "id": 2,
        "report_name": "#1PCS运行周报表",
        "report_type": 2
      },
      {
        "directory_id": 1,
        "id": 3,
        "report_name": "#1PCS运行月报表",
        "report_type": 3
      },
      {
        "directory_id": 1,
        "id": 4,
        "report_name": "#1PCS运行实时报表",
        "report_type": 0
      },
      {
        "directory_id": 1,
        "id": 8295,
        "report_name": "test",
        "report_type": 1
      },
    ];

    const DATA_DIRECTORIES = [
      {
        "directory_name": "储能单元运行报表",
        "id": 1,
        "report_list": []
      }
    ];

    const FILE_CONTENT1 = {
      "data": [{
        "name": "Sheet1", "color": "", "index": 0, "status": 1, "order": 0,
        "celldata": [
          { "r": 0, "c": 1, "v": { "ct": { "fa": "General", "t": "g" }, "m": "系统电压0相", "v": "系统电压0相" } },
          { "r": 0, "c": 2, "v": { "ct": { "fa": "General", "t": "g" }, "m": "系统电压1相", "v": "系统电压1相" } },
          { "r": 0, "c": 3, "v": { "ct": { "fa": "General", "t": "g" }, "m": "系统电压2相", "v": "系统电压2相" } },
          { "r": 1, "c": 0, "v": { "ct": { "fa": "yyyy-MM-dd hh:mm", "t": "d" }, "m": "{\"type\":\"TIME\",\"portrait\":true,\"table_type\":\"ANALOG\",\"data_type\":\"PERIOD\"}", "v": "{\"type\":\"TIME\",\"portrait\":true,\"table_type\":\"ANALOG\",\"data_type\":\"PERIOD\"}" } },
          { "r": 1, "c": 1, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"SEQ\",\"portrait\":true,\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"PERIOD\",\"zero\":false}", "v": "{\"type\":\"SEQ\",\"portrait\":true,\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"PERIOD\",\"zero\":false}" } },
          { "r": 1, "c": 2, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"SEQ\",\"portrait\":true,\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"PERIOD\",\"zero\":false}", "v": "{\"type\":\"SEQ\",\"portrait\":true,\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"PERIOD\",\"zero\":false}" } },
          { "r": 1, "c": 3, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"SEQ\",\"portrait\":true,\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"PERIOD\",\"zero\":false}", "v": "{\"type\":\"SEQ\",\"portrait\":true,\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"PERIOD\",\"zero\":false}" } },
          { "r": 2, "c": 0, "v": { "ct": { "fa": "General", "t": "g" }, "m": "最小值", "v": "最小值" } },
          { "r": 2, "c": 1, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\",\"zero\":false}" } },
          { "r": 2, "c": 2, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\",\"zero\":false}" } },
          { "r": 2, "c": 3, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\",\"zero\":false}" } },
          { "r": 3, "c": 0, "v": { "ct": { "fa": "General", "t": "g" }, "m": "最小值发生时间", "v": "最小值发生时间" } },
          { "r": 3, "c": 1, "v": { "ct": { "fa": "yyyy-MM-dd hh:mm:ss", "t": "d" }, "m": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\"}", "v": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\"}" } },
          { "r": 3, "c": 2, "v": { "ct": { "fa": "yyyy-MM-dd hh:mm:ss", "t": "d" }, "m": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\"}", "v": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\"}" } },
          { "r": 3, "c": 3, "v": { "ct": { "fa": "yyyy-MM-dd hh:mm:ss", "t": "d" }, "m": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\"}", "v": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"MIN\"}" } },
          { "r": 4, "c": 0, "v": { "ct": { "fa": "General", "t": "g" }, "m": "最大值", "v": "最大值" } },
          { "r": 4, "c": 1, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\",\"zero\":false}" } },
          { "r": 4, "c": 2, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\",\"zero\":false}" } },
          { "r": 4, "c": 3, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\",\"zero\":false}" } },
          { "r": 5, "c": 0, "v": { "ct": { "fa": "General", "t": "g" }, "m": "最大值发生时间", "v": "最大值发生时间" } },
          { "r": 5, "c": 1, "v": { "ct": { "fa": "yyyy-MM-dd hh:mm:ss", "t": "d" }, "m": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\"}", "v": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\"}" } },
          { "r": 5, "c": 2, "v": { "ct": { "fa": "yyyy-MM-dd hh:mm:ss", "t": "d" }, "m": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\"}", "v": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\"}" } },
          { "r": 5, "c": 3, "v": { "ct": { "fa": "yyyy-MM-dd hh:mm:ss", "t": "d" }, "m": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\"}", "v": "{\"type\":\"STAT_TIME\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"MAX\"}" } },
          { "r": 6, "c": 0, "v": { "ct": { "fa": "General", "t": "g" }, "m": "平均值", "v": "平均值" } },
          { "r": 6, "c": 1, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"AVG\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"AVG\",\"zero\":false}" } },
          { "r": 6, "c": 2, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"AVG\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"AVG\",\"zero\":false}" } },
          { "r": 6, "c": 3, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"AVG\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"AVG\",\"zero\":false}" } },
          { "r": 7, "c": 0, "v": { "ct": { "fa": "General", "t": "g" }, "m": "电压合格率", "v": "电压合格率" } },
          { "r": 7, "c": 1, "v": { "ct": { "fa": "0.00%", "t": "n" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"VOLT_ELIG\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"VOLT_ELIG\",\"zero\":false}" } },
          { "r": 7, "c": 2, "v": { "ct": { "fa": "0.00%", "t": "n" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"VOLT_ELIG\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"VOLT_ELIG\",\"zero\":false}" } },
          { "r": 7, "c": 3, "v": { "ct": { "fa": "0.00%", "t": "n" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"VOLT_ELIG\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"VOLT_ELIG\",\"zero\":false}" } },
          { "r": 8, "c": 0, "v": { "ct": { "fa": "General", "t": "g" }, "m": "越上限时间", "v": "越上限时间" } },
          { "r": 8, "c": 1, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_HIGH\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_HIGH\",\"zero\":false}" } },
          { "r": 8, "c": 2, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_HIGH\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_HIGH\",\"zero\":false}" } },
          { "r": 8, "c": 3, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_HIGH\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_HIGH\",\"zero\":false}" } },
          { "r": 9, "c": 0, "v": { "ct": { "fa": "General", "t": "g" }, "m": "越下限时间", "v": "越下限时间" } },
          { "r": 9, "c": 1, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_LOW\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:0\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_LOW\",\"zero\":false}" } },
          { "r": 9, "c": 2, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_LOW\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:1\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_LOW\",\"zero\":false}" } },
          { "r": 9, "c": 3, "v": { "ct": { "fa": "General", "t": "g" }, "m": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_LOW\",\"zero\":false}", "v": "{\"type\":\"STAT\",\"id\":\"ANALOG:256:r220:ai:2\",\"table_type\":\"ANALOG\",\"data_type\":\"OVER_TIME_LOW\",\"zero\":false}" } }],
        "config": {},
        "luckysheet_conditionformat_save": [
          {
            "type": "default",
            "cellrange": [
              {
                "row": [1, 1],
                "column": [1, 3],
              }
            ],
            "format": { "textColor": "#ff0000", "cellColor": "#38761d" },
            "conditionName": "greaterThan",
            "conditionRange": [],
            "conditionValue": ["100"]
          }
        ],
        "luckysheet_select_save": [{ "left": 0, "width": 73, "top": 0, "height": 19, "left_move": 0, "width_move": 73, "top_move": 0, "height_move": 19, "row": [0, 0], "column": [0, 0], "row_focus": 0, "column_focus": 0 }],
        "visibledatarow": [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 580, 600, 620, 640, 660, 680, 700, 720, 740, 760, 780, 800, 820, 840, 860, 880, 900, 920, 940, 960, 980, 1000, 1020, 1040, 1060, 1080, 1100, 1120, 1140, 1160, 1180, 1200, 1220, 1240, 1260, 1280, 1300, 1320, 1340, 1360, 1380, 1400, 1420, 1440, 1460, 1480, 1500, 1520, 1540, 1560, 1580, 1600, 1620, 1640, 1660, 1680],
        "visibledatacolumn": [74, 148, 222, 296, 370, 444, 518, 592, 666, 740, 814, 888, 962, 1036, 1110, 1184, 1258, 1332, 1406, 1480, 1554, 1628, 1702, 1776, 1850, 1924, 1998, 2072, 2146, 2220, 2294, 2368, 2442, 2516, 2590, 2664, 2738, 2812, 2886, 2960, 3034, 3108, 3182, 3256, 3330, 3404, 3478, 3552, 3626, 3700, 3774, 3848, 3922, 3996, 4070, 4144, 4218, 4292, 4366, 4440], "ch_width": 4560, "rh_height": 1760,
        "luckysheet_selection_range": [],
        "zoomRatio": 1
      }],
      "config": { "zero": false, "input_username": false, "custom_time_range": true, "auto_build": { "node": null, "time": null, "dir": null, "auto_build_use_date_subdir": false }, "begin_delta": 0, "end_delta": 0, "book_type": "DAY" }
    };
    const FILE_CONTENT4 = {
      "data": [{
        "name": "Sheet1", "color": "", "index": 0, "status": 1, "order": 0,
        "celldata": [{ "r": 0, "c": 1, "v": { "m": "{\"type\":\"ENV\",\"name\":\"REPORT_DATETIME\"}", "ct": { "fa": "General", "t": "g" }, "v": "{\"type\":\"ENV\",\"name\":\"REPORT_DATETIME\"}" } }, { "r": 0, "c": 2, "v": { "m": "{\"type\":\"ENV\",\"name\":\"REPORT_USER\"}", "ct": { "fa": "General", "t": "g" }, "v": "{\"type\":\"ENV\",\"name\":\"REPORT_USER\"}" } }, { "r": 3, "c": 0, "v": { "m": "[思源SVG水冷型]接入点PCC电压AB相", "ct": { "fa": "General", "t": "g" }, "v": "[思源SVG水冷型]接入点PCC电压AB相" } }, { "r": 3, "c": 1, "v": { "m": "[思源SVG水冷型]接入点PCC电压BC相", "ct": { "fa": "General", "t": "g" }, "v": "[思源SVG水冷型]接入点PCC电压BC相" } }, { "r": 3, "c": 2, "v": { "m": "[思源SVG水冷型]接入点PCC电压CA相", "ct": { "fa": "General", "t": "g" }, "v": "[思源SVG水冷型]接入点PCC电压CA相" } }, { "r": 4, "c": 0, "v": { "m": "{\"type\":\"REAL\",\"id\":\"r220:ai:0\",\"table_type\":\"ANALOG\",\"zero\":false}", "ct": { "fa": "General", "t": "g" }, "v": "{\"type\":\"REAL\",\"id\":\"r220:ai:0\",\"table_type\":\"ANALOG\",\"zero\":false}" } }, { "r": 4, "c": 1, "v": { "m": "{\"type\":\"REAL\",\"id\":\"r220:ai:1\",\"table_type\":\"ANALOG\",\"zero\":false}", "ct": { "fa": "General", "t": "g" }, "v": "{\"type\":\"REAL\",\"id\":\"r220:ai:1\",\"table_type\":\"ANALOG\",\"zero\":false}" } }, { "r": 4, "c": 2, "v": { "m": "{\"type\":\"REAL\",\"id\":\"r220:ai:2\",\"table_type\":\"ANALOG\",\"zero\":false}", "ct": { "fa": "General", "t": "g" }, "v": "{\"type\":\"REAL\",\"id\":\"r220:ai:2\",\"table_type\":\"ANALOG\",\"zero\":false}" } }],
        "config": { "merge": {} }, "jfgird_select_save": [], "luckysheet_select_save": [{ "left": 296, "width": 73, "top": 60, "height": 19, "left_move": 296, "width_move": 73, "top_move": 60, "height_move": 19, "row": [3, 3], "column": [4, 4], "row_focus": 3, "column_focus": 4 }], "visibledatarow": [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 580, 600, 620, 640, 660, 680, 700, 720, 740, 760, 780, 800, 820, 840, 860, 880, 900, 920, 940, 960, 980, 1000, 1020, 1040, 1060, 1080, 1100, 1120, 1140, 1160, 1180, 1200, 1220, 1240, 1260, 1280, 1300, 1320, 1340, 1360, 1380, 1400, 1420, 1440, 1460, 1480, 1500, 1520, 1540, 1560, 1580, 1600, 1620, 1640, 1660, 1680], "visibledatacolumn": [74, 148, 222, 296, 370, 444, 518, 592, 666, 740, 814, 888, 962, 1036, 1110, 1184, 1258, 1332, 1406, 1480, 1554, 1628, 1702, 1776, 1850, 1924, 1998, 2072, 2146, 2220, 2294, 2368, 2442, 2516, 2590, 2664, 2738, 2812, 2886, 2960, 3034, 3108, 3182, 3256, 3330, 3404, 3478, 3552, 3626, 3700, 3774, 3848, 3922, 3996, 4070, 4144, 4218, 4292, 4366, 4440], "ch_width": 4560, "rh_height": 1760, "luckysheet_selection_range": [{ "row": [0, 1], "column": [0, 2] }], "zoomRatio": 1, "luckysheet_conditionformat_save": [], "dataVerification": {}, "scrollTop": 0, "scrollLeft": 0
      }],
      "config": { "zero": false, "input_username": false, "custom_time_range": true, "auto_build": { "node": null, "time": null, "dir": null, "auto_build_use_date_subdir": false }, "begin_delta": 0, "end_delta": 0, "book_type": "REAL" }
    };

    this.setJson('DATA_REPORTS', DATA_REPORTS);
    this.setJson('DATA_DIRECTORIES', DATA_DIRECTORIES);
    this.writeFile(ReportFile.getFilePath(DATA_REPORTS[0], HOME_PATH), JSON.stringify(FILE_CONTENT1));
    this.writeFile(ReportFile.getFilePath(DATA_REPORTS[3], HOME_PATH), JSON.stringify(FILE_CONTENT4));
  }
}
const store = new MyMockStore();

const VALUES_SEQ = successResp({
  "value_list": [
    { "time": "2023-03-21 00:00:00.000", "value": "0" },
    { "time": "2023-03-21 01:00:00.000", "value": "1" },
    { "time": "2023-03-21 02:00:00.000", "value": "12524.00" },
    { "time": "2023-03-22 00:00:00.000", "value": "21.00" }
  ]
});
const VALUES_STAT = successResp({
  "value_list": [
    { "time": null, "value": "20.20" }//"2023-03-01 00:00:00.000"
  ]
});
const DATA_DELAY = 0;

export const mock = {
  contexts: {
    text: "XX站XX设备",
    id: 'r221:ai:1',
    path: HOME_PATH,
  },
  showTrigger: true,
  signals: {
    content_changed: {
      cnt: 100,
      x: ['00:00', '02:00', '04:00', '06:00', '08:00', '10:00', '12:00'],
      p: [120, 132, 101, 134, 90, 230, 210],
      r: [220, 182, 191, 234, 290, 330, 310]
    },
    text_changed: "aabbccddeeffgg",
    export_report_changed: {
      report: {
        "directory_id": 1,
        "id": 1,
        "report_name": "#1PCS运行日报表",
        "report_type": 1
      }
    }
  },
  slots: {
    request_history: {
      delay: 5000,
      response: successResp({
        x: [1665813600000, 1665813900000, 1665814200000, 1665814500000, 1665814800000, 1665815100000, 1665815400000, 1665815700000, 1665816000000, 1665816300000, 1665816600000, 1665816900000, 1665817200000, 1665817500000, 1665817800000, 1665818100000, 1665818400000, 1665818700000, 1665819000000, 1665819300000, 1665819600000, 1665819900000, 1665820200000, 1665820500000, 1665820800000, 1665821100000, 1665821400000, 1665821700000, 1665822000000, 1665822300000, 1665822600000, 1665822900000, 1665823200000, 1665823500000, 1665823800000, 1665824100000, 1665824400000, 1665824700000, 1665825000000, 1665825300000, 1665825600000, 1665825900000, 1665826200000, 1665826500000, 1665826800000, 1665827100000, 1665827400000, 1665827700000, 1665828000000, 1665828300000, 1665828600000, 1665828900000, 1665829200000, 1665829500000, 1665829800000, 1665830100000, 1665830400000, 1665830700000, 1665831000000, 1665831300000, 1665831600000, 1665831900000, 1665832200000, 1665832500000, 1665832800000, 1665833100000, 1665833400000, 1665833700000, 1665834000000, 1665834300000, 1665834600000, 1665834900000, 1665835200000, 1665835500000, 1665835800000, 1665836100000, 1665836400000, 1665836700000, 1665837000000, 1665837300000, 1665837600000, 1665837900000, 1665838200000, 1665838500000, 1665838800000, 1665839100000, 1665839400000, 1665839700000, 1665840000000, 1665840300000, 1665840600000, 1665840900000, 1665841200000, 1665841500000, 1665841800000, 1665842100000, 1665842400000, 1665842700000, 1665843000000, 1665843300000, 1665843600000, 1665843900000, 1665844200000, 1665844500000, 1665844800000, 1665845100000, 1665845400000, 1665845700000, 1665846000000, 1665846300000, 1665846600000, 1665846900000, 1665847200000, 1665847500000, 1665847800000, 1665848100000, 1665848400000, 1665848700000, 1665849000000, 1665849300000, 1665849600000, 1665849900000, 1665850200000, 1665850500000, 1665850800000, 1665851100000, 1665851400000, 1665851700000, 1665852000000, 1665852300000, 1665852600000, 1665852900000, 1665853200000, 1665853500000, 1665853800000, 1665854100000, 1665854400000, 1665854700000, 1665855000000, 1665855300000, 1665855600000, 1665855900000, 1665856200000, 1665856500000, 1665856800000, 1665857100000, 1665857400000, 1665857700000, 1665858000000, 1665858300000, 1665858600000, 1665858900000, 1665859200000, 1665859500000, 1665859800000, 1665860100000, 1665860400000, 1665860700000, 1665861000000, 1665861300000, 1665861600000, 1665861900000, 1665862200000, 1665862500000, 1665862800000, 1665863100000, 1665863400000, 1665863700000, 1665864000000, 1665864300000, 1665864600000, 1665864900000, 1665865200000, 1665865500000, 1665865800000, 1665866100000, 1665866400000, 1665866700000, 1665867000000, 1665867300000, 1665867600000, 1665867900000, 1665868200000, 1665868500000, 1665868800000, 1665869100000, 1665869400000, 1665869700000, 1665870000000, 1665870300000, 1665870600000, 1665870900000, 1665871200000, 1665871500000, 1665871800000, 1665872100000, 1665872400000, 1665872700000, 1665873000000, 1665873300000, 1665873600000, 1665873900000, 1665874200000, 1665874500000, 1665874800000, 1665875100000, 1665875400000, 1665875700000, 1665876000000, 1665876300000, 1665876600000, 1665876900000, 1665877200000, 1665877500000, 1665877800000, 1665878100000, 1665878400000, 1665878700000, 1665879000000, 1665879300000, 1665879600000, 1665879900000, 1665880200000, 1665880500000, 1665880800000, 1665881100000, 1665881400000, 1665881700000, 1665882000000, 1665882300000, 1665882600000, 1665882900000, 1665883200000, 1665883500000, 1665883800000, 1665884100000, 1665884400000, 1665884700000, 1665885000000, 1665885300000, 1665885600000, 1665885900000, 1665886200000, 1665886500000, 1665886800000, 1665887100000, 1665887400000, 1665887700000, 1665888000000, 1665888300000, 1665888600000, 1665888900000, 1665889200000, 1665889500000, 1665889800000, 1665890100000, 1665890400000, 1665890700000, 1665891000000, 1665891300000, 1665891600000, 1665891900000, 1665892200000, 1665892500000, 1665892800000, 1665893100000, 1665893400000, 1665893700000, 1665894000000, 1665894300000, 1665894600000, 1665894900000, 1665895200000, 1665895500000, 1665895800000, 1665896100000, 1665896400000, 1665896700000, 1665897000000, 1665897300000, 1665897600000, 1665897900000, 1665898200000, 1665898500000, 1665898800000, 1665899100000, 1665899400000, 1665899700000, 1665900000000],
        s: [86, 30, 193, 258, 410, 235, 90, 108, 595, 336, 793, 1016, 361, 342, 192, 806, 665, 1554, 964, 1169, 782, 979, 902, 1067, 1400, 847, 1398, 1375, 1214, 2336, 2647, 1765, 2406, 2152, 1892, 1894, 2103, 1048, 1380, 822, 958, 1093, 803, 1138, 1448, 1297, 1473, 2458, 1784, 2096, 2070, 1185, 1493, 1338, 2409, 2387, 3054, 2532, 3094, 2664, 3101, 3078, 2581, 2725, 3047, 3088, 3087, 3059, 3165, 3086, 3044, 3078, 1644, 3057, 1218, 2198, 2253, 2615, 3136, 3071, 3058, 3085, 2845, 1872, 2171, 1606, 1486, 2419, 1579, 1212, 815, 808, 1176, 1067, 1377, 541, 201, 833, 498, 1487, 1096, 1655, 2845, 1008, 2716, 1624, 1502, 2644, 360, 742, 1519, 22, 81, 24, 66, 559, 1085, 1175, 118, 3206, 647, 1264, 578, 103, 85, 34, 18, 29, 0, 120, -14, 188, 56, 36, 36, 80, -7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 626, 40, 880, 272, -32, 282, 1122, 1239, 1041, 1626, 1905, 958, 36, 277, 189, 305, 367, 854, 156, 26, 11, 326, 647, 23, 17, 89, 93, 755, 235, 729, 405, 1101, 340, 15, 143, 699, -19, 30, 20, 133, 298, 27, 0, 0, 0, 0, 0, 0, 34, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, 33, 0, 85, 0, 0, 29, 25, 423, 37, 352, 1545, 2047, 812, 1901, 1100, 1397, 942, 1645, 2798, 2315, 2266, 2749, 1634, 3068, 1993, 2432, 1608, 987, 636, 627, 323, 441, 435, 202, -18, 343, 21, 171, 602, 595, 812, 1121, 1763, 2005, 1390, 1610, 1659, 1491, 2234, 1030, 2845, 2769, 3104, 1494, 2306, 1928, 1912, 3055, 2542, 2779, 2111, 2265, 2115, 3066, 2473, 2148, 457, 2290, 1140, 1596, 2134]
      })
    },
    request_advance: {
      delay: 5000,
      response: successResp({
        x: ['00:00', '02:00', '04:00', '06:00', '08:00', '10:00', '12:00'],
        p: [120, 132, 101, 134, 90, 230, 210],
        r: [220, 182, 191, 234, 290, 330, 310]
      })
    },
    request_get_report_list: {
      delay: 1000,
      response: () => {
        const dir_list = store.getJson('DATA_DIRECTORIES');
        const report_list = store.getJson('DATA_REPORTS');
        for (const report of report_list) {
          const dir = dir_list.find(catalog => catalog.id === report.directory_id);
          if (!dir) {
            continue;
          }
          if (!dir.report_list) {
            dir.report_list = [];
          }
          dir.report_list.push(report);
        }
        return successResp({ "report_directory": dir_list });
      }
    },
    request_insert_directory: {
      delay: 5000,
      response: (param) => {
        const { directory_name } = param;
        const id = Math.floor(Math.random() * 10000);
        const catalog = { "directory_name": directory_name, "id": id }
        const dir_list = store.getJson('DATA_DIRECTORIES');
        dir_list.push(catalog);
        store.setJson('DATA_DIRECTORIES', dir_list);
        return successResp(catalog);
      }
    },
    request_insert_report: {
      delay: 3000,
      response: (param) => {
        const { directory_id, report_type, report_name,
          auto_generate, generate_time, generate_node, generate_path, generate_subdirectory } = param;

        const dir_list = store.getJson('DATA_DIRECTORIES');
        const catalog = dir_list.find(catalog => catalog.id === directory_id);
        if (!catalog) {
          throw new Error('directory not found');
        }

        const id = Math.floor(Math.random() * 10000);
        const report = {
          "id": id,
          directory_id, report_name, report_type,
          auto_generate, generate_time, generate_node, generate_path, generate_subdirectory
        };

        const report_list = store.getJson('DATA_REPORTS');
        report_list.push(report);
        store.setJson('DATA_REPORTS', report_list);
        return successResp({ "report": report });
      }
    },
    request_delete_directory: {
      delay: 3000,
      response: (param) => {
        const { id } = param;

        const dir_list = store.getJson('DATA_DIRECTORIES');
        const index = dir_list.findIndex(catalog => catalog.id === id);
        if (index === -1) {
          throw new Error('directory not found');
        }
        dir_list.splice(index, 1);
        store.setJson('DATA_DIRECTORIES', dir_list);
        return successResp();
      }
    },
    request_delete_report: {
      delay: 3000,
      response: (param) => {
        const { id } = param;

        const report_list = store.getJson('DATA_REPORTS');
        const index = report_list.findIndex(report => report.id === id);
        if (index === -1) {
          throw new Error('report not found');
        }
        report_list.splice(index, 1);
        store.setJson('DATA_REPORTS', report_list);
        return successResp();
      }
    },
    request_update_directory: {
      delay: 3000,
      response: (param) => {
        const { id, directory_name } = param;

        const dir_list = store.getJson('DATA_DIRECTORIES');
        const catalog = dir_list.find(catalog => catalog.id === id);
        if (!catalog) {
          throw new Error('directory not found');
        }
        catalog.directory_name = directory_name;
        store.setJson('DATA_DIRECTORIES', dir_list);
        return successResp();
      }
    },
    request_update_report: {
      delay: 3000,
      response: (param) => {
        const { id, directory_id, report_type, report_name,
          auto_generate, generate_time, generate_node, generate_path, generate_subdirectory } = param;

        const report_list = store.getJson('DATA_REPORTS');
        const report = report_list.find(report => report.id === id);
        if (!report) {
          throw new Error('report not found');
        }
        Object.assign(report, {
          directory_id, report_type, report_name,
          auto_generate, generate_time, generate_node, generate_path, generate_subdirectory
        });
        store.setJson('DATA_REPORTS', report_list);
        return successResp();
      }
    },

    request_open_file: {
      delay: 0,
      response: (param) => {
        const { file_path } = param;
        let tpl = store.readFile(file_path);
        return successResp({ file_content: tpl });
      }
    },
    request_save_file: {
      delay: 0,
      response: (param) => {
        const { report_id, file_path, file_content } = param
        const fpath = ReportFile.getFilePath({ id: report_id }, file_path);
        store.writeFile(fpath, file_content);
        return successResp();
      }
    },

    request_get_sys_node_list: {
      response: successResp({
        "node_list": [
          { "node_desc": "ems" },
          { "node_desc": "oper1" },
          { "node_desc": "oper2" }
        ]
      })
    },

    request_get_terminal_list: {
      delay: 0,
      response: successResp({
        "station_list": [
          {
            "station_id": "sda:lsc",
            "station_desc": "郎山储能",
            "terminal_list": [
              {
                "terminal_desc": "#1PCS",
                "terminal_no": 256,
                "terminal_type": 3 // 终端类型,0:缺省类型,1:保护,2:测控,3:交流器,4:BMS,5:通信管理机,6:计算量
              },
              {
                "terminal_desc": "#2PCS",
                "terminal_no": 257,
                "terminal_type": 3
              },
              {
                "terminal_desc": "#3PCS",
                "terminal_no": 258,
                "terminal_type": 3
              }
            ]
          }
        ]
      })
    },
    request_get_model_node_list: {
      delay: 0,
      response: successResp({
        "model_node_list": [
          {
            "station_id": "sda:lsc",
            "station_desc": "郎山储能",
            "bay_list": [
              {
                "bay_id": 1004,
                "bay_desc": "#1PCS",
                "device_list": [
                  {
                    "device_id": 1800,
                    "device_desc": "#1PCS",
                  }
                ]
              },
              {
                "bay_id": 1005,
                "bay_desc": "#2PCS",
                "device_list": [
                  {
                    "device_id": 1801,
                    "device_desc": "#2PCS",
                  }
                ]
              }
            ]
          }
        ]
      })
    },

    request_get_point_list: {
      delay: 1000,
      response: (param) => {
        // table_type 表类型,0:遥测参数表,1:遥信参数表2:电度参数表
        const { data_type, device_id } = param;
        const prefix = data_type + ':' + device_id + ':r220:ai:';
        const list = [];
        for (let i = 0; i < 2000; i++) {
          list.push({ point_id: prefix + i, point_desc: `系统电压${i}相`, point_type: 127 });
        }
        return successResp({ point_list: list });
      }
    },

    request_get_point_desc: {
      delay: 3000,
      // (point_id, data_type)
      response: successResp({
        "point": {
          "point_desc": "交流AB线电压",
          "device_desc": "#1PCS",
          "bay_desc": "#1PCS",
          "station_desc": "XXX储能电站",
        }
      })
    },

    // 周期值序列数据获取
    request_get_period_value_seq: {
      delay: DATA_DELAY,
      // (id, from, to)
      response: VALUES_SEQ
    },
    // 平均值序列数据获取
    request_get_mean_value_seq: {
      delay: DATA_DELAY,
      // (id, from, to, report_type)
      response: VALUES_SEQ
    },
    // 最大值序列数据获取
    request_get_max_value_seq: {
      delay: DATA_DELAY,
      // (id, from, to, report_type)
      response: VALUES_SEQ
    },
    // 最小值序列数据获取
    request_get_min_value_seq: {
      delay: DATA_DELAY,
      // (id, from, to, report_type)
      response: VALUES_SEQ
    },
    // 差值序列数据获取
    request_get_diff_value_seq: {
      delay: DATA_DELAY,
      // (id, from, to, report_type)
      response: VALUES_SEQ
    },
    // 末值序列数据获取
    request_get_last_value_seq: {
      delay: DATA_DELAY,
      // (id, from, to, report_type)
      response: VALUES_SEQ
    },
    // 平均值统计数据获取
    request_get_mean_value_stats: {
      delay: DATA_DELAY,
      // (id, time, report_type)
      response: VALUES_STAT
    },
    // 最大值统计数据获取
    request_get_max_value_stats: {
      delay: DATA_DELAY,
      // (id, time, report_type)
      response: VALUES_STAT
    },
    // 最小值统计数据获取
    request_get_min_value_stats: {
      delay: DATA_DELAY,
      // (id, time, report_type)
      response: VALUES_STAT
    },
    // 平均值绝对统计数据获取
    request_get_mean_value_abs_stats: {
      delay: DATA_DELAY,
      // (id, time, report_type)
      response: VALUES_STAT
    },
    // 最大值绝对统计数据获取
    request_get_max_value_abs_stats: {
      delay: DATA_DELAY,
      // (id, time, report_type)
      response: VALUES_STAT
    },
    // 最小值绝对统计数据获取
    request_get_min_value_abs_stats: {
      delay: DATA_DELAY,
      // (id, time, report_type)
      response: VALUES_STAT
    },
    // 越上限时间计算统计获取
    request_get_over_limit_time_h: {
      delay: DATA_DELAY,
      // (id, time, report_type)
      response: successResp({
        "high_limit_time": "1278"
      })
    },
    // 越下限时间计算统计获取
    request_get_over_limit_time_l: {
      delay: DATA_DELAY,
      // (id, time, report_type)
      response: successResp({
        "low_limit_time": "1278"
      })
    },
    // 电压合格率计算统计获取
    request_get_voltage_eligibility_rate: {
      delay: DATA_DELAY,
      // (id, time, report_type)
      response: successResp({
        "voltage_eligibility_rate": "0.9612"
      })
    },
    // 测点实时值获取
    request_get_point_value_real: {
      delay: DATA_DELAY,
      // (id, table_type)
      response: successResp({
        "point_value": "1278"
      })
    },
  }
};